/*
 * Copyright (C) 2010-2101 Alibaba Group Holding Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.alibaba.otter.manager.biz.config.datacolumnpair.dal;

import com.alibaba.otter.manager.biz.dto.CommonSearchDTO;
import com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO;
import com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.ColumnPairGroupDO;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.data.domain.Pageable;

import java.util.List;

/**
 * 类DataColumnPairGroupDAO.java的实现描述：TODO 类实现描述
 *
 * @author simon 2012-4-20 下午4:09:09
 */
public interface DataColumnPairGroupDao extends BaseMapper<ColumnPairGroupDO> {


    long uniqueInsert(ColumnPairGroupDO columnPairGroupDO);

    void deleteByDataMediaPairId(Long dataMediaPairId);

    List<ColumnPairGroupDO> ListByDataMediaPairId(Long dataMediaPairId);

    List<ColumnPairGroupDO> ListByDataMediaPairIds(Long... dataMediaPairIds);

    default Page<ColumnPairGroupDO> dataColumnPairGroupPage(CommonSearchDTO searchVo, Pageable pageable){
        QueryWrapper q = QueryWrapper.create().eq(CanalDO::getName, searchVo.getName(), StringUtils::isNotBlank);
        return paginate(pageable.getPageNumber(), pageable.getPageSize(), q);
    }
}
